﻿<%@ Page Title="" Language="C#" MasterPageFile="~/MasterPages/Frontend.master" AutoEventWireup="true" CodeFile="Default.aspx.cs" Inherits="Reviews_Default" %>

<asp:Content ID="Content1" ContentPlaceHolderID="head" runat="Server">
</asp:Content>
<asp:Content ID="Content2" ContentPlaceHolderID="ContentPlaceHolder1" runat="Server">
    <div class="mainbar">
        <asp:UpdatePanel ID="UpdatePanel1" runat="server">
            <ContentTemplate>
                <asp:ListView ID="ListView1" runat="server" DataKeyNames="Id" DataSourceID="SqlDataSource2" GroupItemCount="3">
                    <EmptyDataTemplate>
                        <table runat="server" style="">
                            <tr>
                                <td>No data was returned.</td>
                            </tr>
                        </table>
                    </EmptyDataTemplate>
                    <EmptyItemTemplate>
                        <td runat="server" />
                    </EmptyItemTemplate>
                    <GroupTemplate>
                        <tr id="itemPlaceholderContainer" runat="server">
                            <td id="itemPlaceholder" runat="server"></td>
                        </tr>
                    </GroupTemplate>
                    <ItemTemplate>
                        <td runat="server" style="width: 200px;">
                            <asp:HyperLink ID="HyperLink1" runat="server" NavigateUrl='<%# "~/Reviews/Detail.aspx?Id="+Eval("Id") %>'>
                                <asp:Label ID="NameLabel" runat="server" Text='<%# Eval("Name") %>' />
                                <br />
                                <asp:Image CssClass="fotoReview" ID="Image1" runat="server" ImageUrl='<%# Eval("ImageUrl") %>' Width="200" />
                                <br />
                            </asp:HyperLink></td>
                    </ItemTemplate>
                    <LayoutTemplate>
                        <table runat="server">
                            <tr runat="server">
                                <td runat="server">
                                    <table id="groupPlaceholderContainer" runat="server" border="0" style="">
                                        <tr id="groupPlaceholder" runat="server">
                                        </tr>
                                    </table>
                                </td>
                            </tr>
                            <tr runat="server">
                                <td runat="server" style="">
                                    <asp:DataPager ID="DataPager1" runat="server" PageSize="12">
                                        <Fields>
                                            <asp:NextPreviousPagerField ButtonType="Button" ShowFirstPageButton="True" ShowNextPageButton="False" ShowPreviousPageButton="False" />
                                            <asp:NumericPagerField />
                                            <asp:NextPreviousPagerField ButtonType="Button" ShowLastPageButton="True" ShowNextPageButton="False" ShowPreviousPageButton="False" />
                                        </Fields>
                                    </asp:DataPager>
                                </td>
                            </tr>
                        </table>
                    </LayoutTemplate>
                </asp:ListView>
                <asp:SqlDataSource ID="SqlDataSource2" runat="server" ConnectionString="<%$ ConnectionStrings:ProjectASPConnectionString %>" SelectCommand="SELECT Products.Id, Products.Name, Products.Type, MIN(Pictures.ImageUrl) AS ImageUrl FROM Products INNER JOIN Pictures ON Products.Id = Pictures.Product GROUP BY Products.Id, Products.Name, Products.Type" FilterExpression="Type={0}">
                    <FilterParameters>
                        <asp:QueryStringParameter Name="Category" QueryStringField="Category" />
                    </FilterParameters>
                </asp:SqlDataSource>
                <br />
            </ContentTemplate>
        </asp:UpdatePanel>
    </div>
    <div class="sidebar">

        <div class="gadget">
            <p>
                <asp:GridView ID="GridView1" runat="server" AutoGenerateColumns="False" DataKeyNames="Id" DataSourceID="SqlDataSource1" EmptyDataText="There are no data records to display." CssClass="tabelData">
                    <Columns>
                        <asp:HyperLinkField DataNavigateUrlFields="Id" DataNavigateUrlFormatString="~/Reviews/Default.aspx?Category={0}" DataTextField="Name" HeaderText="Categories" />
                    </Columns>
                </asp:GridView>
                <asp:HyperLink CssClass="HyperlData" ID="HyperLink2" runat="server" NavigateUrl="~/Reviews/Default.aspx">Show all</asp:HyperLink><asp:SqlDataSource ID="SqlDataSource1" runat="server" ConnectionString="<%$ ConnectionStrings:LocalSqlServer %>" DeleteCommand="DELETE FROM [ProductType] WHERE [Id] = @Id" InsertCommand="INSERT INTO [ProductType] ([Name], [Description]) VALUES (@Name, @Description)" ProviderName="<%$ ConnectionStrings:LocalSqlServer.ProviderName %>" SelectCommand="SELECT [Id], [Name], [Description] FROM [ProductType]" UpdateCommand="UPDATE [ProductType] SET [Name] = @Name, [Description] = @Description WHERE [Id] = @Id">
                    <DeleteParameters>
                        <asp:Parameter Name="Id" Type="Int32" />
                    </DeleteParameters>
                    <InsertParameters>
                        <asp:Parameter Name="Name" Type="String" />
                        <asp:Parameter Name="Description" Type="String" />
                    </InsertParameters>
                    <UpdateParameters>
                        <asp:Parameter Name="Name" Type="String" />
                        <asp:Parameter Name="Description" Type="String" />
                        <asp:Parameter Name="Id" Type="Int32" />
                    </UpdateParameters>
                </asp:SqlDataSource>
            </p>
        </div>
    </div>
</asp:Content>

